package bartenderqueue;

import drinkkiosk.drinks.SpecialDrink;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import networktool.BartenderClient;

/**ExitButton is a JButton on the manager card
 * that exits the program when touched
 * @author Charles Ritchea
 */
public class ExitButton extends JButton implements ActionListener{
	/**ExitButton() this constructor sets the Icon of the button, clears the
	 * text, and attaches the ActionListener
	 */
	public ExitButton() {
		super();
		setIcon(new ImageIcon(getClass().getResource("/bartenderqueue/shutdown-button-th.png")));
		addActionListener(this);
	}
	/**actionPerformed will exit the program when this button is touched.
	 * @param e ActionEvent when ExitButton is touched
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
        try {
            BartenderClient.sendDrink(new SpecialDrink("offline","","","","","","",""));
        } catch (IOException ex) {
            Logger.getLogger(ExitButton.class.getName()).log(Level.SEVERE, null, ex);
        }
		System.exit(0);
	}
}